package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Demo10 {
    public static void main(String[] args) {
        try (Connection con=DBUtil.getConnection();){
            String sql="INSERT INTO user(username,password,nickname,age) "+
                       "VALUES (?,?,?,?)";
            PreparedStatement pre=con.prepareStatement(sql);
            pre.setString(1,"宁姚");
            pre.setInt(2,123456);
            pre.setString(3,"剑仙");
            pre.setInt(4,19);
            int num=pre.executeUpdate();
            System.out.println(num>0?"插入成功":"插入失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
